package com.jinzhi.jzweb.controller;


import com.baomidou.mybatisplus.plugins.Page;
import com.jinzhi.common.annotation.Log;
import com.jinzhi.common.base.BaseController;
import com.jinzhi.common.utils.Result;
import com.jinzhi.jzweb.domain.ArchivesDO;
import com.jinzhi.jzweb.domain.ArchivesFollowDO;
import com.jinzhi.jzweb.service.ArchivesFollowService;
import com.jinzhi.jzweb.service.ArchivesService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 
 * <pre>
 * 
 * </pre>
 * <small> 2021-08-09 09:27:28 | lance</small>
 */
@Controller
@RequestMapping("/jzweb/archivesFollowList")
public class ArchivesSchoolListController extends BaseController {
	@Autowired
	private ArchivesFollowService archivesFollowService;
	@Autowired
	private ArchivesService archivesService;

	@GetMapping()
	@RequiresPermissions("jzweb:archives:archList")
	String ArchivesFollow(String schoolName,Model model){

		model.addAttribute("schoolName",schoolName);
		return "jzweb/archives/archivesFollowList";
	}

	@ResponseBody
	@GetMapping("/list")
	@RequiresPermissions("jzweb:archives:archives")
	public Result<Page<ArchivesFollowDO>> list(String schoolName) {
			// 查询列表数据
		Page<ArchivesFollowDO> page = archivesFollowService.selectPage(getPage(ArchivesFollowDO.class),
				archivesFollowService.convertToEntityWrapper().orderBy("id", false).eq("school_name",schoolName));
		List list = new ArrayList();
		for (int i = 0; i < page.getRecords().size(); i++) {
			ArchivesFollowDO obj = (ArchivesFollowDO) page.getRecords().get(i);
			list.add(obj);
		}
		page.setRecords(list);
		return Result.ok(page);

	}
}
